﻿@using ZBJF.Warranty.BLL
@using ZBJF.Warranty.Common.Enums.InsuranceWarranty
@using EnumHelper = ZBJF.Warranty.Common.Common.EnumHelper
@model  ZBJF.Warranty.Model.InsuranceWarrantyRecord
@{
    var lastServiceUser = ServiceFactory.InsuranceWarrantyRecordServiceUserServiceInstance.LoadLastServiceUser(Model.ID) ?? Model.SystemUser;
}
<h4>工单信息</h4>
<table class="table table-responsive table-bordered table-hover">
    <tr>
        <th>工单号</th>
        <th>创建人</th>
        <th>工单状态</th>
        <th>上名跟单人</th>
        <th>操作</th>
    </tr>
    <tr>
        <td>
            @Model.WarrantyRecordNo
        </td>
        <td>
            @Model.CreateBy
        </td>
        <td>
            <label class="red"> @EnumHelper.Instance.GetDescription(typeof(InsuranceWarrantyStatus), Model.Status)</label>
        </td>
        <td>
            @(lastServiceUser != null ? lastServiceUser.UserDisPlayName : "")
        </td>
        <td>
            @if (ServiceFactory.InsuranceWarrantyRecordStatusServiceInstance.GetParentStatusCode(Model.Status) == (byte)InsuranceWarrantyStatus.Processing)
            {
                <a onclick="CareOf()">转交工单</a>
            }
        </td>
    </tr>
</table>
<script type="text/javascript">
    var CareOfIndex;
    function CareOf(parameters) {
        //转交工单
        CareOfIndex=layer.open({
            type: 1,
            title: '转交工单', //标题栏
            closeBtn: false,
            area: '300px;',
            shade: 0.8,
            id: 'LAY_CareOf', //设定一个id，防止重复弹出
            resize: false,
            btn: ['确认', '取消'],
            btnAlign: 'c', //按钮排列
            yes: function (index, layero) {
                SaveInsuranceWarrantyRecordServiceUser();
            },
            moveType: 1, //拖拽模式，0或者1
            content: $('#transferOrderModal').show()
        });
    }

    function SaveInsuranceWarrantyRecordServiceUser(parameters) {
        var takeOverOrderServiceUserID = $("#TakeOverOrderServiceUserID").val();
        if (takeOverOrderServiceUserID <=0) {
            layer.alert("请选择转交人");
            return false;
        }
        $.ajax({
            url: "/ToBeMaintainWorkOrder/SaveInsuranceWarrantyRecordServiceUser?ID="+@Model.ID,
            dataType: "json",
            type: "post",
            data: {
                InsuranceWarrantyRecordID:"@Model.ID",
                TransferOrderServiceUserID:"@Model.SystemServiceUserId",
                TakeOverOrderServiceUserID:takeOverOrderServiceUserID
            },
            success: function(data) {
                if (data.Success) {
                    layer.close(CareOfIndex);
                    layer.alert(data.Message);
                    location.reload();
                    return;
                }
            }
        });
    }
</script>